// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.16.10
package sysin

import (
	"context"
	"hotgo/internal/consts"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"
	"hotgo/utility/validate"

	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

// ActivityUserUpdateFields 修改活动用户管理字段过滤
type ActivityUserUpdateFields struct {
	ActivityId int    `json:"activityId" dc:"活动id"`
	Name       string `json:"name"       dc:"姓名"`
	Number     string `json:"number"     dc:"参赛号"`
	Phone      string `json:"phone"      dc:"手机号"`
	Area       string `json:"area"       dc:"地区"`
	Pb         string `json:"pb"         dc:"PB"`
	Target     string `json:"target"     dc:"目标"`
	IdCard     string `json:"idCard"     dc:"身份证号"`
	Status     int    `json:"status"     dc:"状态"`
}

// ActivityUserInsertFields 新增活动用户管理字段过滤
type ActivityUserInsertFields struct {
	ActivityId int    `json:"activityId" dc:"活动id"`
	Name       string `json:"name"       dc:"姓名"`
	Number     string `json:"number"     dc:"参赛号"`
	Phone      string `json:"phone"      dc:"手机号"`
	Area       string `json:"area"       dc:"地区"`
	Pb         string `json:"pb"         dc:"PB"`
	Target     string `json:"target"     dc:"目标"`
	IdCard     string `json:"idCard"     dc:"身份证号"`
	Status     int    `json:"status"     dc:"状态"`
}

// ActivityUserEditInp 修改/新增活动用户管理
type ActivityUserEditInp struct {
	entity.ActivityUser
}

func (in *ActivityUserEditInp) Filter(ctx context.Context) (err error) {
	// 验证活动id
	if err := g.Validator().Rules("required").Data(in.ActivityId).Messages("活动id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证姓名
	if err := g.Validator().Rules("required").Data(in.Name).Messages("姓名不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证身份证号
	if err := g.Validator().Rules("resident-id").Data(in.IdCard).Messages("身份证号不是身份证号码").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type ActivityUserEditModel struct{}

// ActivityUserDeleteInp 删除活动用户管理
type ActivityUserDeleteInp struct {
	Id interface{} `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *ActivityUserDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type ActivityUserDeleteModel struct{}

// ActivityUserViewInp 获取指定活动用户管理信息
type ActivityUserViewInp struct {
	Id int `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *ActivityUserViewInp) Filter(ctx context.Context) (err error) {
	return
}

type ActivityUserViewModel struct {
	entity.ActivityUser
}

// ActivityUserListInp 获取活动用户管理列表
type ActivityUserListInp struct {
	form.PageReq
	Name          string `json:"name"          dc:"姓名"`
	Number        string `json:"number"        dc:"参赛号"`
	IdCard        string `json:"idCard"        dc:"身份证号"`
	Status        int    `json:"status"        dc:"状态"`
	ActivityTitle string `json:"activityTitle" dc:"活动名称"`
}

func (in *ActivityUserListInp) Filter(ctx context.Context) (err error) {
	return
}

type ActivityUserListModel struct {
	Id            int         `json:"id"            dc:"id"`
	Name          string      `json:"name"          dc:"姓名"`
	Number        string      `json:"number"        dc:"参赛号"`
	Phone         string      `json:"phone"         dc:"手机号"`
	Area          string      `json:"area"          dc:"地区"`
	Pb            string      `json:"pb"            dc:"PB"`
	Target        string      `json:"target"        dc:"目标"`
	IdCard        string      `json:"idCard"        dc:"身份证号"`
	CreateAt      *gtime.Time `json:"createAt"      dc:"添加时间"`
	UpdateAt      *gtime.Time `json:"updateAt"      dc:"更新时间"`
	Status        int         `json:"status"        dc:"状态"`
	ActivityTitle string      `json:"activityTitle" dc:"活动名称"`
}

// ActivityUserExportModel 导出活动用户管理
type ActivityUserExportModel struct {
	Id            int         `json:"id"            dc:"id"`
	ActivityId    int         `json:"activityId"    dc:"活动id"`
	Name          string      `json:"name"          dc:"姓名"`
	Number        string      `json:"number"        dc:"参赛号"`
	Phone         string      `json:"phone"         dc:"手机号"`
	Area          string      `json:"area"          dc:"地区"`
	Pb            string      `json:"pb"            dc:"PB"`
	Target        string      `json:"target"        dc:"目标"`
	IdCard        string      `json:"idCard"        dc:"身份证号"`
	CreateAt      *gtime.Time `json:"createAt"      dc:"添加时间"`
	UpdateAt      *gtime.Time `json:"updateAt"      dc:"更新时间"`
	Status        int         `json:"status"        dc:"状态"`
	ActivityTitle string      `json:"activityTitle" dc:"活动名称"`
}

// ActivityUserStatusInp 更新活动用户管理状态
type ActivityUserStatusInp struct {
	Id     int `json:"id" v:"required#id不能为空" dc:"id"`
	Status int `json:"status" dc:"状态"`
}

func (in *ActivityUserStatusInp) Filter(ctx context.Context) (err error) {
	if in.Id <= 0 {
		err = gerror.New("id不能为空")
		return
	}

	if in.Status <= 0 {
		err = gerror.New("状态不能为空")
		return
	}

	if !validate.InSlice(consts.StatusSlice, in.Status) {
		err = gerror.New("状态不正确")
		return
	}
	return
}

type ActivityUserStatusModel struct{}